﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using UniversityStudentManagemnetSystem.DAO.DAL;
using UniversityStudentManagemnetSystem.DAO.DAL.Gateway;
using UniversityStudentManagemnetSystem.DAO.Gateway;

namespace UniversityStudentManagemnetSystem.BLL
{
    public class CourseManager
    {
        CourseGateway courseGateway = new CourseGateway();
        public bool SaveCourse(Course course)
        {
            if (courseGateway.GetHasThisCourseCode(course.Code) && courseGateway.GetHasThisCourseName(course.CourseName))
            {
                throw new Exception("This Course Code and Course Name already Exit.");
            }
            else if (courseGateway.GetHasThisCourseCode(course.Code))
            {
                throw new Exception("This Course Code already Exit.");
            }
            else if (courseGateway.GetHasThisCourseName(course.CourseName))
            {
                throw new Exception("This Course Name already Exit.");  
            }
            else
            {
                return courseGateway.CourseSave(course);   
            }
        }

        public DataTable GetAllCourses()
        {
            return courseGateway.GetCourses();
        }
        public DataTable GetAllCoursesOf(int selectedDepartment)
        {
            return courseGateway.GetAllCourseFor(selectedDepartment);
        }
    }
}